package aiaudio.storage.simple;

import aiaudio.storage.api.IArtist;
import aiaudio.storage.api.IAudioTestSet;
import aiaudio.storage.api.IAudioTrainingSet;
import aiaudio.storage.api.ITrainingStorage;
import aiaudio.storage.api.IUser;
import aiaudio.storage.api.RevereUserArtistTuple;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 *
 * @author Nastya
 */
public abstract class TrainingStorage implements ITrainingStorage {

    private List<IAudioTrainingSet> trainingSets = new ArrayList<IAudioTrainingSet>();
    private IAudioTestSet testSet;

    public TrainingStorage(List<IUser> users, List<IArtist> artists,
            HashMap<RevereUserArtistTuple, Double> ratings)
            throws TooManyItemsException {
        splitToTrainingSets(users, artists, ratings);
    }

    @Override
    public int trainingSetCount() {
        return trainingSets.size();
    }

    @Override
    public IAudioTrainingSet getTrainingSet(int index) {
        return trainingSets.get(index);
    }

    @Override
    public IAudioTestSet getTestSet() {
        return testSet;
    }

    protected boolean addTrainingSetSet(IAudioTrainingSet e) {
        return trainingSets.add(e);
    }

    protected void setTestSet(IAudioTestSet testSet) {
        this.testSet = testSet;
    }

    protected abstract void splitToTrainingSets(List<IUser> users,
            List<IArtist> artists, HashMap<RevereUserArtistTuple, Double> ratings)
            throws TooManyItemsException;
}
